<template>
  <view style="padding-bottom: 120rpx">
    <u-navbar
      v-if="!$isWeixin()"
      :customBack="backToHome"
      :title="title"
      :titleBold="true"
      :background="{ backgroundColor: '#ffffff' }"
      :is-fixed="true"
    ></u-navbar>

    <u-tabs active-color="#FF7A23" :list="tabList" :current="tabIndex" @change="index => (tabIndex = index)"></u-tabs>

    <view v-if="tabIndex == 0" style="padding: 0 20rpx">
      <!-- <u-checkbox-group @change="onSelectedFieldChange">
				<u-checkbox v-model="item.checked" v-for="(item, index) in fieldOptions" :key="index" :name="item.value">{{ item.label }}</u-checkbox>
			</u-checkbox-group> -->

      <view v-for="(item, index) in fieldsOptions" :key="index" style="margin-bottom: 20rpx">
        <u-section :title="item.title" :right="false" style="margin-bottom: 20rpx">
          <template #right>
            <text v-if="index == 0 && Update_Count == 0" style="color: #ee0a24;font-size: 10px;">
              经销商信息维护首次更新信息,需维护全部信息
            </text>
          </template>
        </u-section>

        <u-checkbox v-model="item.checked" :disabled="Update_Count == 0" @change="onCheckAllChange($event, item)">
          全选
        </u-checkbox>

        <u-checkbox-group style="width: 100%" @change="onSelectedFieldChange($event, item)">
          <view style="width: 100%">
            <u-checkbox
              :disabled="Update_Count == 0"
              v-model="field.checked"
              v-for="(field, fi) in item.fields"
              :key="fi"
              :name="field.value"
            >
              {{ field.label }}
            </u-checkbox>
          </view>
        </u-checkbox-group>
      </view>
    </view>

    <block class="" v-if="ShowLevel == 3">
      <view class="" v-show="tabIndex == 1">
        <u-cell-item
          :arrow="false"
          :border-bottom="true"
          title="一级经销商名称"
          :value="First_Dealer_BaseInfo.Name"
        ></u-cell-item>
        <u-cell-item
          :arrow="false"
          :border-bottom="false"
          title="二级经销商名称"
          :value="Double_Dealer_BaseInfo.Name"
        ></u-cell-item>

        <basic-information-form
          :selectedFields="selectedFields"
          :displayAll="false"
          :loadCity="loadCity"
          ref="basicForm"
          :level="ShowLevel"
          :showLevel="false"
          :metadata="DataBaseInfo"
          :showApplyReason="false"
          :showSalesInfo="false"
        ></basic-information-form>

        <block v-if="selectedFields.includes(16)">
          <u-cell-item title="人员数量" :arrow="false" style="" :border-bottom="false"></u-cell-item>

          <u-cell-item title="" :arrow="false">
            <u-button @tap="addPersonCount" type="warning" size="mini">添加</u-button>

            <view class="u-flex u-text-right" v-for="(item, index) in form.DealerPeopleNumList" :key="index">
              <u-input v-model="item.Title" placeholder="请输入标题" :border="true" :height="50"></u-input>
              <text class="u-m-20">:</text>
              <u-input v-model="item.Num" type="number" placeholder="数量" :border="true" :height="50"></u-input>
              <u-button @tap="removePersonCount(index)" style="margin-left: 20rpx" type="error" size="mini">
                删除
              </u-button>
            </view>
          </u-cell-item>
        </block>
      </view>

      <view class="" v-show="tabIndex == 2" style="">
        <u-cell-group style="background-color: #eceaef">
          <!-- <u-cell-item v-if="selectedFields.includes(19)" title="BDR销售台数" :arrow="false">
						<view class="u-flex">
							<u-input style="text-align: right;" v-model="form.VisitRecordInfo.SalesVolume" placeholder="请输入BDR销售台数" :customStyle="{ borderBottom: true }"></u-input>
							台
						</view>
					</u-cell-item> -->
          <!-- <u-cell-item v-if="selectedFields.includes(20)" title="总销售台数" :arrow="false">
						<view class="u-flex">
							<u-input style="text-align: right;" v-model="form.VisitRecordInfo.TotalSalesVolume" placeholder="请输入总销售台数" :customStyle="{ borderBottom: true }"></u-input>
							台
						</view>
					</u-cell-item> -->
          <!-- <u-cell-item title="销售台数占比" :arrow="false">
						<view class="u-flex">
							<u-input disabled style="text-align: right;" :value="percentOfSalesVolume" placeholder="" :customStyle="{ borderBottom: true }"></u-input>
							%
						</view>
					</u-cell-item> -->

          <u-cell-item v-if="selectedFields.includes(8)" required :arrow="false" title="属性">
            <u-radio-group v-model="form.This_Dealer_OtherInfo.DealerType">
              <view class="grid-2">
                <u-radio
                  :label-size="26"
                  v-for="(item, index) in DataBaseInfo.DealerType_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-radio>
              </view>
            </u-radio-group>
          </u-cell-item>
          <u-cell-item v-if="selectedFields.includes(9)" required :arrow="false" title="经营品类">
            <u-checkbox-group @change="onBusinessCategoryChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  v-for="(item, index) in DataBaseInfo.BusinessCategory_BaseList"
                  :name="item.Key"
                  :key="index"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
          </u-cell-item>

          <u-cell-item
            v-if="selectedFields.includes(10) || selectedFields.includes(11) || selectedFields.includes(12)"
            required
            :arrow="false"
            title="竞品品牌"
          >
            <block v-if="selectedFields.includes(10)">
              <view class="u-text-left u-p-l-20">BDR品牌数: {{ count_A }}</view>
              <u-checkbox-group @change="onCompetingGoodsBrandAChange">
                <view class="grid-2">
                  <u-checkbox
                    :label-size="26"
                    v-model="item.checked"
                    v-for="(item, index) in DataBaseInfo.CompetingGoodsBrandA_BaseList"
                    :key="index"
                    :name="item.Key"
                  >
                    {{ item.Value }}
                  </u-checkbox>
                </view>
              </u-checkbox-group>
              <u-line></u-line>
            </block>

            <block v-if="selectedFields.includes(11)">
              <view class="u-text-left u-p-l-20">进口品牌数: {{ count_B }}</view>
              <u-checkbox-group @change="onCompetingGoodsBrandBChange">
                <view class="grid-2">
                  <u-checkbox
                    :label-size="26"
                    v-model="item.checked"
                    class="grid-item"
                    v-for="(item, index) in DataBaseInfo.CompetingGoodsBrandB_BaseList"
                    :key="index"
                    :name="item.Key"
                  >
                    {{ item.Value }}
                  </u-checkbox>
                </view>
              </u-checkbox-group>
              <u-line></u-line>
            </block>

            <block v-if="selectedFields.includes(12)">
              <view class="u-text-left u-p-l-20">国产品牌数: {{ count_C }}</view>
              <u-checkbox-group @change="onCompetingGoodsBrandCChange">
                <view class="grid-2">
                  <u-checkbox
                    :label-size="26"
                    v-model="item.checked"
                    v-for="(item, index) in DataBaseInfo.CompetingGoodsBrandC_BaseList"
                    :key="index"
                    :name="item.Key"
                  >
                    {{ item.Value }}
                  </u-checkbox>
                </view>
              </u-checkbox-group>
            </block>
          </u-cell-item>

          <block v-if="selectedFields.includes(21)">
            <u-cell-item title="竞品出样情况" :arrow="false" :border-bottom="false">
              <u-radio-group v-model="form.VisitRecordInfo.Sampling">
                <u-radio name="1">是</u-radio>
                <u-radio name="2">否</u-radio>
              </u-radio-group>
            </u-cell-item>

            <u-cell-item title="" style="padding: 0" :arrow="false">
              <view class="u-m-20" v-if="form.VisitRecordInfo.Sampling == 1">
                <view
                  class="samling-item"
                  v-for="(item, index) in form.VisitRecordInfo.DealerSamplingSellList"
                  :key="index"
                >
                  <u-button @tap="removeSampling(index)" type="error" size="mini" class="u-m-b-10">删除</u-button>
                  <u-input v-model="item.BrandName" :border="true"></u-input>
                  <u-input v-model="item.ProductModel" class="u-m-t-10" :border="true"></u-input>
                  <u-input
                    class="u-m-t-10"
                    type="number"
                    :border="true"
                    placeholder="数量"
                    v-model="item.Number"
                  ></u-input>

                  <u-gap bg-color="#f5f5f5" class="u-m-t-10 u-m-b-10" :height="10"></u-gap>
                </view>

                <view class="u-text-right u-m-t-10 u-m-b-10 u-p-r-40">
                  <u-button @tap="addSampling" type="warning" size="mini">添加竞品样机</u-button>
                </view>
              </view>
            </u-cell-item>
          </block>

          <!-- <block v-if="selectedFields.includes(22)">
						<u-cell-item title="竞品走访备注" :arrow="false" style="padding-bottom: 0;" :border-bottom="false"></u-cell-item>
						<u-cell-item :arrow="false" style="padding: 0rpx 40rpx;"><u-input type="textarea" v-model="form.VisitRecordInfo.VisitRemake"></u-input></u-cell-item>
					</block> -->

          <!-- <block v-if="selectedFields.includes(25)">
						<u-cell-item title="我司其他信息" :arrow="false" style="padding-bottom: 0;" :border-bottom="false"></u-cell-item>
						<u-cell-item :arrow="false" style="padding: 0rpx 40rpx;"><u-input type="textarea" v-model="form.VisitRecordInfo.ProductOtherInfo"></u-input></u-cell-item>
					</block> -->

          <block v-if="selectedFields.includes(23)">
            <u-cell-item title="样机情况" :arrow="false" :border-bottom="false"></u-cell-item>
            <u-cell-item style="padding: 0" :arrow="false">
              <view class="u-m-20">
                <view
                  class="samling-item"
                  v-for="(item, index) in form.VisitRecordInfo.DealerVisitSellList"
                  :key="index"
                >
                  <u-button @tap="removeVisitSell(index)" type="error" size="mini" class="u-m-b-10">删除</u-button>
                  <u-input
                    type="select"
                    :value="item.BrandName"
                    :border="true"
                    @tap="(showVisitSellPicker = true), (currentVisitSellIndex = index)"
                    :selectOpen="showVisitSellPicker"
                  ></u-input>
                  <u-input
                    :value="item.productName"
                    class="u-m-t-10"
                    type="select"
                    @tap="(showVisitSellProductPicker = true), (currentVisitSellIndex = index)"
                    :selectOpen="showVisitSellProductPicker"
                    :border="true"
                  ></u-input>
                  <u-input
                    class="u-m-t-10"
                    type="number"
                    :border="true"
                    placeholder="数量"
                    v-model="item.Number"
                  ></u-input>

                  <u-gap bg-color="#f5f5f5" class="u-m-t-10 u-m-b-10" :height="10"></u-gap>
                </view>

                <view class="u-text-right u-m-t-10 u-m-b-10 u-p-r-40">
                  <u-button @tap="addVisitSell" type="warning" size="mini">添加BDR样机情况</u-button>
                </view>
              </view>
            </u-cell-item>
          </block>

          <!-- <block v-if="selectedFields.includes(24)">
						<u-cell-item title="是否经营两联供" :arrow="false">
							<u-radio-group v-model="form.VisitRecordInfo.DoubleSupply">
								<u-radio :name="1">是</u-radio>
								<u-radio :name="2">否</u-radio>
							</u-radio-group>
						</u-cell-item>
						<block v-if="form.VisitRecordInfo.DoubleSupply == 1">
							<u-cell-item title="两联供品牌" :arrow="false">
								<u-checkbox-group @change="onDoubleSupplyChange">
									<u-checkbox v-for="(item, index) in doubleApplyBrandList" :key="index" v-model="item.checked" :name="item.Key">{{ item.Value }}</u-checkbox>
								</u-checkbox-group>
							</u-cell-item>
							<u-cell-item title="其他品牌" :arrow="false">
								<u-input style="text-align: right;" v-model="form.VisitRecordInfo.OtherBrand" placeholder="其他品牌"></u-input>
							</u-cell-item>
						</block>
					</block> -->
        </u-cell-group>
      </view>

      <!-- 销售信息 -->
      <view class="" v-show="tabIndex == 3">
        <u-cell-item v-if="selectedFields.includes(13)" required :arrow="false" title="上年BDR销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                type="number"
                inputAlign="right"
                placeholder="请输入"
                v-model.number="form.This_Dealer_OtherInfo.LastYearsBDRSales"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
            <text class="desc">*BDR品牌的年销售额，新开的可预估</text>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(14)" required :arrow="false" title="总销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                type="number"
                inputAlign="right"
                placeholder="请输入"
                v-model.number="form.This_Dealer_OtherInfo.TotalSales"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
            <text class="desc">*所有品类的年销售额</text>
          </view>
        </u-cell-item>
        <u-cell-item v-if="selectedFields.includes(15)" required :arrow="false" title="BDR销售额占比">
          <view class="u-flex-col u-col-bottom">
            <view>
              <text>
                {{
                  !form.This_Dealer_OtherInfo.TotalSales
                    ? ''
                    : (
                        (form.This_Dealer_OtherInfo.LastYearsBDRSales / form.This_Dealer_OtherInfo.TotalSales) *
                        100
                      ).toFixed(0)
                }}%
              </text>
              <text class="unit"></text>
            </view>
            <text class="desc">*上年BDR销售额/总销售额</text>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(34)" :arrow="false" title="上一年对应代理商供暖销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_DealerHeatingSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(35)" :arrow="false" title="上一年对应代理商空凋销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_DealerAirConditionerSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(36)" :arrow="false" title="上一年对应代理商净水销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_DealerPurifiedWaterSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(50)" :arrow="false" title="上一年门店供暖销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_StoreHeatingSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(51)" :arrow="false" title="上一年门店空凋销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_StoreAirConditionerSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(52)" :arrow="false" title="上一年门店净水销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(53)" :arrow="false" title="上一年销售BDR供暖产品台数">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(54)" :arrow="false" title="上一年销售BDR净水产品台数">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(55)" :arrow="false" title="上一年销售BDR热泵产品台数">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.This_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>
      </view>

      <view class="" v-show="tabIndex == 4">
        <u-cell-group>
          <u-cell-item v-if="selectedFields.includes(38)" :arrow="false" title="新店所属市级区域供暖市场容量">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.AS_HeatingMarketCapacity"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">台</text>
              </view>
            </view>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(39)" :arrow="false" title="新店所属市级区域热泵市场容量">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.AS_HeatPumpMarketCapacity"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">台</text>
              </view>
            </view>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(40)" :arrow="false" title="周边1公里竞品门店数">
            <u-input
              v-model="form.This_Dealer_OtherInfo.AS_CompetingStoresNum"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(41)" :arrow="false" title="周边1公里竞品品牌">
            <u-input
              v-model="form.This_Dealer_OtherInfo.AS_CompetingBrand"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(42)" :arrow="false" title="周边1公里竞品做最好的品牌">
            <u-input
              v-model="form.This_Dealer_OtherInfo.AS_BestCompetingBrand"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(43)" :arrow="false" title="周边1公里竞品做最好品牌的年供暖销售额">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">万元</text>
              </view>
            </view>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(44)" :arrow="false" title="周边1公里竞品做最好品牌的年热泵销售额">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">万元</text>
              </view>
            </view>
          </u-cell-item>

          <block v-if="selectedFields.includes(45)">
            <u-cell-item title="开店原因" :arrow="false" style="padding-bottom: 0" :border-bottom="false"></u-cell-item>
            <u-cell-item :arrow="false" style="padding: 0rpx 40rpx">
              <u-input type="textarea" v-model="form.This_Dealer_OtherInfo.AS_ReasonOpeningStore"></u-input>
            </u-cell-item>
          </block>

          <u-cell-item v-if="selectedFields.includes(46)" :arrow="false" title="新店预估年壁挂炉台数">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.NY_Estimate_FireplaceNum"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">台</text>
              </view>
            </view>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(47)" :arrow="false" title="新店预估年净水台数">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.NY_Estimate_CleanWaterNum"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">台</text>
              </view>
            </view>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(56)" :arrow="false" title="新店预估年热泵台数">
            <view class="u-flex-col u-col-bottom">
              <view class="u-flex">
                <u-input
                  v-model="form.This_Dealer_OtherInfo.NY_Estimate_HeatPumpNum"
                  type="number"
                  inputAlign="right"
                  placeholder="请输入"
                ></u-input>
                <text class="unit u-m-l-32">台</text>
              </view>
            </view>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(48)" :arrow="false" title="补贴方式">
            <u-radio-group v-model="form.This_Dealer_OtherInfo.SubsidyMethod" disabled>
              <u-radio name="1">现金</u-radio>
              <u-radio name="2">市场返利</u-radio>
            </u-radio-group>
          </u-cell-item>

          <u-cell-item v-if="selectedFields.includes(57)" :arrow="false" title="申请类型">
            <u-radio-group v-model="form.This_Dealer_OtherInfo.StoreApplyType">
              <u-radio name="1">焕新</u-radio>
              <u-radio name="2">新建</u-radio>
            </u-radio-group>
          </u-cell-item>
        </u-cell-group>
      </view>

      <view class="" v-show="tabIndex == 5">
        <block v-if="selectedFields.includes(60)">
          <u-cell-group>
            <u-cell-item title="门店等级" :arrow="false">
              <u-radio-group v-model="form.VisitRecordInfo.FlagshipState">
                <view class="grid-2">
                  <u-radio v-for="(item, index) in DealerGrade_VisitList" :key="index" :name="item.Key">
                    {{ item.Value }}
                  </u-radio>
                </view>
              </u-radio-group>
            </u-cell-item>

            <u-cell-item title="走访模块" :arrow="false" :border-bottom="false"></u-cell-item>
            <u-cell-item title="" :arrow="false" style="padding: 0 20rpx">
              <u-checkbox-group>
                <view class="visit-grid">
                  <view class="visit-item" v-for="(item, index) in DealerVisitCategorylistModel" :key="index">
                    <view class="title u-line-1 u-m-b-10">
                      <u-checkbox v-model="item.checked" :name="item.Id">
                        <text>{{ item.Name }}</text>
                        <text style="color: red" v-if="item.Id == 1">*</text>
                      </u-checkbox>
                    </view>
                    <u-image
                      @tap="selectFile(index)"
                      :width="180"
                      :height="180"
                      :src="$getImageUrl(item.Pic)"
                    ></u-image>
                  </view>
                </view>
              </u-checkbox-group>
            </u-cell-item>
          </u-cell-group>
        </block>
      </view>

      <view class="" v-show="tabIndex == 6">
        <boss-information-form
          :showIsVip="true"
          :selectedFields="selectedFields"
          :displayAll="false"
          ref="bossForm"
        ></boss-information-form>
      </view>

      <!-- 门店照片 -->
      <view class="" v-show="tabIndex == 7"><store-photo :list="DoorPhotoList"></store-photo></view>

      <!-- 门店开户照片 -->
      <view class="" v-show="tabIndex == 8">
        <new-store-photo v-model="form.InitialStorePhoto" :showAdd="false"></new-store-photo>
      </view>

      <view class="" v-show="tabIndex == 9">
        <u-cell-item title="审核流品牌" :arrow="false" :border-bottom="false" required>
          <u-radio-group v-model="form.Aub_Brand">
            <view class="grid-2">
              <u-radio :label-size="26" :name="5">八喜</u-radio>
              <u-radio :label-size="26" :name="6">夏贝</u-radio>
              <u-radio :label-size="26" :name="7">德地氏</u-radio>
              <u-radio :label-size="26" :name="8">伯爵</u-radio>
              <u-radio :label-size="26" :name="0">无</u-radio>
            </view>
          </u-radio-group>
        </u-cell-item>
        <u-cell-item :arrow="false" style="padding: 0 30rpx">
          <view style="color: red; text-align: left">
            请选择审核流品牌，此选项是根据所选品牌指定对应审核流，选择“无”代表无需根据品牌判断使用指定审核流，在所选品牌查找不到审核流信息时，会查询所有审核流中的第一条做为审核流程
          </view>
        </u-cell-item>
        <apply-form ref="applyForm"></apply-form>
      </view>
    </block>

    <block class="" v-else>
      <view class="" v-show="tabIndex == 1">
        <u-cell-item
          :arrow="false"
          :border-bottom="false"
          v-if="ShowLevel != 1"
          title="一级经销商名称"
          :value="First_Dealer_BaseInfo.Name"
        ></u-cell-item>

        <basic-information-form
          :selectedFields="selectedFields"
          :displayAll="false"
          :loadCity="loadCity"
          ref="basicForm"
          :level="ShowLevel"
          :metadata="DataBaseInfo"
          :showApplyReason="false"
          :showSalesInfo="false"
        ></basic-information-form>
      </view>

      <view class="" v-show="tabIndex == 2">
        <!-- <u-cell-item v-if="selectedFields.includes(58)" required :arrow="false" title="渠道类型">
					// 1：渠道   2：售后   3：渠道+售后   4：供应商   5：公司  6：其他 
					<u-radio-group v-model="form.This_Dealer_OtherInfo.ChannelType">
						<view class="grid-2">
							<u-radio name="1">渠道</u-radio>
							<u-radio name="2">售后</u-radio>
							<u-radio name="3">渠道+售后</u-radio>
							<u-radio name="4">供应商</u-radio>
							<u-radio name="5">公司</u-radio>
							<u-radio name="6">其他</u-radio>
						</view>
					</u-radio-group>
				</u-cell-item> -->

        <u-cell-item v-if="selectedFields.includes(59) && ShowLevel == 1" required :arrow="false" title="类型">
          <u-checkbox-group @change="onFirstTypeChange">
            <view class="grid-2">
              <!-- 1：民用   2：商用   3：民用+商用  4：其他-->
              <u-checkbox
                :label-size="26"
                :name="item.Key"
                v-model="item.checked"
                v-for="(item, index) in First_Type_List"
                :key="index"
              >
                {{ item.Value }}
              </u-checkbox>
            </view>
          </u-checkbox-group>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(8)" required :arrow="false" title="属性">
          <u-radio-group v-model="form.This_Dealer_OtherInfo.DealerType">
            <view class="grid-2">
              <u-radio
                :label-size="26"
                v-for="(item, index) in DataBaseInfo.DealerType_BaseList"
                :key="index"
                :name="item.Key"
              >
                {{ item.Value }}
              </u-radio>
            </view>
          </u-radio-group>
        </u-cell-item>
        <u-cell-item v-if="selectedFields.includes(9)" required :arrow="false" title="经营品类">
          <u-checkbox-group @change="onBusinessCategoryChange">
            <view class="grid-2">
              <u-checkbox
                :label-size="26"
                v-model="item.checked"
                v-for="(item, index) in DataBaseInfo.BusinessCategory_BaseList"
                :name="item.Key"
                :key="index"
              >
                {{ item.Value }}
              </u-checkbox>
            </view>
          </u-checkbox-group>
        </u-cell-item>

        <u-cell-item
          v-if="selectedFields.includes(10) || selectedFields.includes(11) || selectedFields.includes(12)"
          required
          :arrow="false"
          title="竞品品牌"
        >
          <block v-if="selectedFields.includes(10)">
            <view class="u-text-left u-p-l-20">BDR品牌数: {{ count_A }}</view>
            <u-checkbox-group @change="onCompetingGoodsBrandAChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  v-for="(item, index) in DataBaseInfo.CompetingGoodsBrandA_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
            <u-line></u-line>
          </block>

          <block v-if="selectedFields.includes(11)">
            <view class="u-text-left u-p-l-20">进口品牌数: {{ count_B }}</view>
            <u-checkbox-group @change="onCompetingGoodsBrandBChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  class="grid-item"
                  v-for="(item, index) in DataBaseInfo.CompetingGoodsBrandB_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
            <u-line></u-line>
          </block>

          <block v-if="selectedFields.includes(12)">
            <view class="u-text-left u-p-l-20">国产品牌数: {{ count_C }}</view>
            <u-checkbox-group @change="onCompetingGoodsBrandCChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  v-for="(item, index) in DataBaseInfo.CompetingGoodsBrandC_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
          </block>
        </u-cell-item>
      </view>

      <view class="" v-show="tabIndex == 3">
        <u-cell-item v-if="selectedFields.includes(13)" required :arrow="false" title="上年BDR销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                type="number"
                inputAlign="right"
                placeholder="请输入"
                v-model.number="form.This_Dealer_OtherInfo.LastYearsBDRSales"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
            <text class="desc">*BDR品牌的年销售额，新开的可预估</text>
          </view>
        </u-cell-item>

        <u-cell-item v-if="selectedFields.includes(14)" required :arrow="false" title="总销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                type="number"
                inputAlign="right"
                placeholder="请输入"
                v-model.number="form.This_Dealer_OtherInfo.TotalSales"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
            <text class="desc">*所有品类的年销售额</text>
          </view>
        </u-cell-item>
        <u-cell-item v-if="selectedFields.includes(15)" required :arrow="false" title="BDR销售额占比">
          <view class="u-flex-col u-col-bottom">
            <view>
              <text>
                {{
                  !form.This_Dealer_OtherInfo.TotalSales
                    ? ''
                    : (
                        (form.This_Dealer_OtherInfo.LastYearsBDRSales / form.This_Dealer_OtherInfo.TotalSales) *
                        100
                      ).toFixed(0)
                }}%
              </text>
              <text class="unit"></text>
            </view>
            <text class="desc">*上年BDR销售额/总销售额</text>
          </view>
        </u-cell-item>
      </view>

      <view class="" v-show="tabIndex == 4">
        <boss-information-form
          :showIsVip="true"
          :selectedFields="selectedFields"
          :displayAll="false"
          ref="bossForm"
        ></boss-information-form>
      </view>

      <!-- 	<view class="" v-show="ShowLevel == 1 && tabIndex == 3">
				<relations-form v-show="selectedFields.includes(0)" @remove="removeRelation" :metadata="relationsMetaData" ref="relationsForm"></relations-form>
			</view> -->

      <view class="" v-show="tabIndex == 5">
        <u-cell-item title="审核流品牌" :arrow="false" :border-bottom="false" required>
          <u-radio-group v-model="form.Aub_Brand">
            <view class="grid-2">
              <u-radio :label-size="26" :name="5">八喜</u-radio>
              <u-radio :label-size="26" :name="6">夏贝</u-radio>
              <u-radio :label-size="26" :name="7">德地氏</u-radio>
              <u-radio :label-size="26" :name="8">伯爵</u-radio>
              <u-radio :label-size="26" :name="0">无</u-radio>
            </view>
          </u-radio-group>
        </u-cell-item>
        <u-cell-item :arrow="false" style="padding: 0 30rpx">
          <view style="color: red; text-align: left">
            请选择审核流品牌，此选项是根据所选品牌指定对应审核流，选择“无”代表无需根据品牌判断使用指定审核流，在所选品牌查找不到审核流信息时，会查询所有审核流中的第一条做为审核流程
          </view>
        </u-cell-item>

        <apply-form ref="applyForm"></apply-form>
      </view>
    </block>

    <view class="btn-group-fixed" v-if="!loading">
      <!-- <u-button @click="backToList">返回列表</u-button> -->
      <u-button :disabled="btnDisabled" type="warning" @click="submit">保存提交</u-button>
    </view>

    <u-upload
      style="display: none"
      class="upload-item"
      ref="upload"
      :show-progress="false"
      :auto-upload="false"
      @on-choose-complete="onFileChange"
      @on-remove="deleteFile"
    ></u-upload>

    <u-select
      @confirm="onPickerChange($event, currentSamplingIndex)"
      :default-value="[
        this.form.VisitRecordInfo.DealerSamplingSellList[currentSamplingIndex]
          ? this.form.VisitRecordInfo.DealerSamplingSellList[currentSamplingIndex].brandIndex
          : -1
      ]"
      v-model="showBrandPicker"
      :list="DataBaseInfo.CompetingGoodsBrandA_BaseList"
      label-name="Value"
      value-name="Key"
      safe-area-inset-bottom
    ></u-select>

    <u-select
      @confirm="onVisitSellPickerChange($event, currentVisitSellIndex)"
      :default-value="[
        form.VisitRecordInfo.DealerVisitSellList[currentVisitSellIndex]
          ? form.VisitRecordInfo.DealerVisitSellList[currentVisitSellIndex].brandIndex
          : -1
      ]"
      v-model="showVisitSellPicker"
      :list="DataBaseInfo.CompetingGoodsBrandA_BaseList"
      label-name="Value"
      value-name="Key"
      safe-area-inset-bottom
    ></u-select>

    <u-select
      @confirm="onProductPickerChange($event, currentSamplingIndex, 1)"
      :default-value="[0]"
      v-model="showProductPicker"
      :list="
        form.VisitRecordInfo.DealerSamplingSellList[currentSamplingIndex]
          ? form.VisitRecordInfo.DealerSamplingSellList[currentSamplingIndex].productList
          : []
      "
      label-name="Text"
      value-name="Id"
      safe-area-inset-bottom
    ></u-select>

    <u-select
      @confirm="onProductPickerChange($event, currentVisitSellIndex, 2)"
      :default-value="[0]"
      v-model="showVisitSellProductPicker"
      :list="
        form.VisitRecordInfo.DealerVisitSellList[currentVisitSellIndex]
          ? form.VisitRecordInfo.DealerVisitSellList[currentVisitSellIndex].productList
          : []
      "
      label-name="Text"
      value-name="Id"
      safe-area-inset-bottom
    ></u-select>
  </view>
</template>

<script>
export default {
  data() {
    return {
      btnDisabled: false,

      ShowLevel: null,
      title: '渠道信息更新',

      loading: false,

      Update_Count: 0,

      level1TabList: [
        { name: '修改字段' },
        { name: '基础信息' },
        { name: '产品信息' },
        { name: '销售信息' },
        { name: '老板信息' },
        { name: '申请备注' }
      ],
      level2TabList: [
        { name: '修改字段' },
        { name: '基础信息' },
        { name: '产品信息' },
        { name: '销售信息' },
        { name: '老板信息' },
        { name: '申请备注' }
      ],

      level3TabList: [
        { name: '修改字段' },
        { name: '基础信息' },
        { name: '产品信息' },
        { name: '销售信息' },
        { name: '门店周边情况' },
        { name: '门店展陈信息' },
        { name: '老板信息' },
        { name: '门店照片' },
        { name: '门店开户照片' },
        { name: '申请备注' }
      ],

      First_Type_List: [],

      tabIndex: 0,

      loadCity: false,

      DataBaseInfo: {},
      DealerAuditInfo: {},
      DoorPhotoAuditInfo: {},
      DoorPhotoList: [],
      Door_Dealer_BaseInfo: {},
      Double_Dealer_BaseInfo: {},
      First_Dealer_BaseInfo: {},
      This_Dealer_OtherInfo: {},
      This_Dealer_RelationList: [],

      relationsMetaData: {},

      DealerGrade_VisitList: [],

      DealerVisitCategorylistModel: [],

      currentIndex: 0,

      showBrandPicker: false,

      currentSamplingIndex: 0,

      showProductPicker: false,

      showVisitSellProductPicker: false,

      productOptions: [],

      currentVisitSellIndex: 0,
      showVisitSellPicker: false,

      doubleApplyBrandList: [
        { name: '约克', checked: false },
        { name: '特灵', checked: false },
        { name: '开利', checked: false },
        { name: '三菱', checked: false }
      ],

      otherInfo: {
        AS_HeatingMarketCapacity: '',
        AS_HeatPumpMarketCapacity: '',
        AS_CompetingStoresNum: '',
        AS_CompetingBrand: '',
        AS_BestCompetingBrand: '',
        AS_AnnualHeatingSalesCompetingProducts: '',
        AS_CompetitiveAnnualHeatPumpSales: '',
        AS_ReasonOpeningStore: '',

        NY_Estimate_FireplaceNum: '',
        NY_Estimate_CleanWaterNum: '',
        NY_Estimate_HeatPumpNum: '',

        SubsidyMethod: '1',
        StoreApplyType: ''
      },

      selectedFields: [],
      displayAll: false,

      fieldOptions_1: [
        {
          title: '基础信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '经销商名称', value: 1, checked: false },
            { label: '简称', value: 2, checked: false },
            { label: '负责人名称', value: 3, checked: false },
            { label: '负责人手机号', value: 4, checked: false },
            { label: '地址', value: 5, checked: false },
            { label: '证照', value: 6, checked: false },
            { label: '经销协议', value: 7, checked: false },
            { label: '人员数量', value: 16, checked: false }
          ]
        },
        {
          title: '产品信息',
          checked: false,
          selectedFields: [],
          fields: [
            // { label: '渠道类型', value: 58, checked: false },
            { label: '类型', value: 59, checked: false },
            { label: '属性', value: 8, checked: false },
            { label: '经营品类', value: 9, checked: false },
            { label: 'BDR品牌数', value: 10, checked: false },
            { label: '进口品牌数', value: 11, checked: false },
            { label: '国产品牌数', value: 12, checked: false }
            // { label: '竞品出样情况', value: 21, checked: false },
            // { label: '样机情况', value: 23, checked: false },
            // { label: '竞品走访备注', value: 22, checked: false },
            // { label: '是否经营两联供', value: 24, checked: false },
            // { label: '我司产品其他信息', value: 25, checked: false }
          ]
        },
        {
          title: '销售信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '上年BDR销售额', value: 13, checked: false },
            { label: '总销售额', value: 14, checked: false }
          ]
        },
        {
          title: '老板信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '老板名称', value: 26, checked: false },
            { label: '老板手机号', value: 27, checked: false },
            { label: '老板生日', value: 28, checked: false },
            { label: '是否是VIP', value: 29, checked: false },
            { label: '祝福备注', value: 30, checked: false }
          ]
        }
      ],
      fieldOptions_2: [
        {
          title: '基础信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '经销商名称', value: 1, checked: false },
            { label: '简称', value: 2, checked: false },
            { label: '负责人名称', value: 3, checked: false },
            { label: '负责人手机号', value: 4, checked: false },
            { label: '地址', value: 5, checked: false },
            { label: '证照', value: 6, checked: false },
            { label: '经销协议', value: 7, checked: false },
            { label: '人员数量', value: 16, checked: false }
          ]
        },
        {
          title: '产品信息',
          checked: false,
          selectedFields: [],
          fields: [
            // { label: '渠道类型', value: 58, checked: false },
            { label: '属性', value: 8, checked: false },
            { label: '经营品类', value: 9, checked: false },
            { label: 'BDR品牌数', value: 10, checked: false },
            { label: '进口品牌数', value: 11, checked: false },
            { label: '国产品牌数', value: 12, checked: false }
            // { label: '竞品出样情况', value: 21, checked: false },
            // { label: '样机情况', value: 23, checked: false },
            // { label: '竞品走访备注', value: 22, checked: false },
            // { label: '是否经营两联供', value: 24, checked: false },
            // { label: '我司产品其他信息', value: 25, checked: false }
          ]
        },
        {
          title: '销售信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '上年BDR销售额', value: 13, checked: false },
            { label: '总销售额', value: 14, checked: false }
          ]
        },
        {
          title: '老板信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '老板名称', value: 26, checked: false },
            { label: '老板手机号', value: 27, checked: false },
            { label: '老板生日', value: 28, checked: false },
            { label: '是否是VIP', value: 29, checked: false },
            { label: '祝福备注', value: 30, checked: false }
          ]
        }
      ],
      fieldOptions_3: [
        {
          title: '基础信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '经销商名称', value: 1, checked: false },
            { label: '简称', value: 2, checked: false },
            { label: '负责人名称', value: 3, checked: false },
            { label: '负责人手机号', value: 4, checked: false },
            { label: '地址', value: 5, checked: false },
            { label: '门店位置', value: 31, checked: false },
            { label: 'BDR面积', value: 32, checked: false },
            { label: '店内面积', value: 33, checked: false },
            { label: '其他产品占用面积', value: 49, checked: false },
            { label: '门店人员数量', value: 16, checked: false }
            // { label: '门店等级', value: 17, checked: false }
          ]
        },

        {
          title: '产品信息',
          checked: false,
          selectedFields: [],
          fields: [
            // { label: '属性', value: 8, checked: false },
            { label: '经营品类', value: 9, checked: false },
            { label: 'BDR品牌数', value: 10, checked: false },
            { label: '进口品牌数', value: 11, checked: false },
            { label: '国产品牌数', value: 12, checked: false },
            { label: '竞品出样情况', value: 21, checked: false },
            { label: '样机情况', value: 23, checked: false }
            // { label: '竞品走访备注', value: 22, checked: false },
            // { label: '是否经营两联供', value: 24, checked: false },
            // { label: '我司产品其他信息', value: 25, checked: false }
          ]
        },
        {
          title: '销售信息',
          checked: false,
          selectedFields: [],
          fields: [
            // { label: '上年BDR销售额', value: 13, checked: false },
            // { label: '总销售额', value: 14, checked: false },
            // { label: 'BDR销售台数', value: 19, checked: false },
            // { label: '总销售台数', value: 20, checked: false },
            { label: '上一年对应代理商供暖销售额', value: 34, checked: false },
            { label: '上一年对应代理商空凋销售额', value: 35, checked: false },
            { label: '上一年对应代理商净水销售额', value: 36, checked: false },
            { label: '上一年此门店供暖销售额', value: 50, checked: false },
            { label: '上一年此门店空调销售额', value: 51, checked: false },
            { label: '上一年此门店净水销售额', value: 52, checked: false },
            {
              label: '上一年此门店销售BDR供暖产品台数',
              value: 53,
              checked: false
            },
            {
              label: '上一年此门店销售BDR净水产品台数',
              value: 54,
              checked: false
            },
            {
              label: '上一年此门店销售BDR热泵产品台数',
              value: 55,
              checked: false
            }
          ]
        },
        {
          title: '门店周边情况',
          checked: false,
          selectedFields: [],
          fields: [
            {
              label: '新店所属市级区域供暖市场容量',
              value: 38,
              checked: false
            },
            {
              label: '新店所属市级区域热泵市场容量',
              value: 39,
              checked: false
            },
            { label: '周边1公里竞品门店数', value: 40, checked: false },
            { label: '周边1公里竞品品牌', value: 41, checked: false },
            { label: '周边1公里竞品做最好的品牌', value: 42, checked: false },
            {
              label: '周边1公里竞品做最好品牌的年供暖销售额',
              value: 43,
              checked: false
            },
            {
              label: '周边1公里竞品做最好品牌的年热泵销售额',
              value: 44,
              checked: false
            },
            { label: '开店原因', value: 45, checked: false },
            { label: '新店预估年壁挂炉台数', value: 46, checked: false },
            { label: '新店预估年净水台数', value: 47, checked: false },
            { label: '新店预估年热泵台数', value: 56, checked: false }
            // { label: '补贴方式', value: 48, checked: false },
            // { label: '门店申请类型', value: 57, checked: false }
          ]
        },
        {
          title: '门店展陈信息',
          checked: false,
          selectedFields: [],
          fields: [
            // { label: '门店等级', value: 17, checked: false },
            // { label: '走访模块', value: 18, checked: false },
            { label: '店铺等级', value: 60, checked: false }
          ]
        },
        {
          title: '老板信息',
          checked: false,
          selectedFields: [],
          fields: [
            { label: '老板名称', value: 26, checked: false },
            { label: '老板手机号', value: 27, checked: false },
            { label: '老板生日', value: 28, checked: false },
            { label: '是否是VIP', value: 29, checked: false },
            { label: '祝福备注', value: 30, checked: false }
          ]
        }
      ],

      fieldOptions: [
        { label: '销售业务关系', value: 0, checked: false },
        { label: '经销商名称', value: 1, checked: false },
        { label: '简称', value: 2, checked: false },
        { label: '负责人名称', value: 3, checked: false },
        { label: '负责人手机号', value: 4, checked: false },
        { label: '地址', value: 5, checked: false },
        { label: '证照', value: 6, checked: false },
        { label: '经销协议', value: 7, checked: false },
        { label: '属性', value: 8, checked: false },
        { label: '经营品类', value: 9, checked: false },
        { label: 'BDR品牌数', value: 10, checked: false },
        { label: '进口品牌数', value: 11, checked: false },
        { label: '国产品牌数', value: 12, checked: false },
        { label: '上年BDR销售额', value: 13, checked: false },
        { label: '总销售额', value: 14, checked: false },
        { label: 'BDR销售占比', value: 15, checked: false },
        { label: '人员数量', value: 16, checked: false },
        { label: '信息收集门店等级', value: 17, checked: false },
        { label: '走访模块', value: 18, checked: false },
        { label: 'BDR销售台数', value: 19, checked: false },
        { label: '总销售台数', value: 20, checked: false },
        { label: '竞品出样情况', value: 21, checked: false },
        { label: '竞品走访备注', value: 22, checked: false },
        { label: '样机情况', value: 23, checked: false },
        { label: '是否经营两联供', value: 24, checked: false },
        { label: '我司产品其他信息', value: 25, checked: false },
        { label: '老板名称', value: 26, checked: false },
        { label: '老板手机号', value: 27, checked: false },
        { label: '老板生日', value: 28, checked: false },
        { label: '是否是VIP', value: 29, checked: false },
        { label: '祝福备注', value: 30, checked: false },
        { label: '门店位置', value: 31, checked: false },
        { label: 'BDR面积', value: 32, checked: false },
        { label: '店内面积', value: 33, checked: false },
        { label: '上一年对应代理商供暖销售额', value: 34, checked: false },
        { label: '上一年对应代理商空凋销售额', value: 35, checked: false },
        { label: '上一年对应代理商净水销售额', value: 36, checked: false },
        { label: '新店所属市级区域供暖市场容量', value: 38, checked: false },
        { label: '新店所属市级区域热泵市场容量', value: 39, checked: false },
        { label: '周边1公里竞品门店数', value: 40, checked: false },
        { label: '周边1公里竞品品牌', value: 41, checked: false },
        { label: '周边1公里竞品做最好的品牌', value: 42, checked: false },
        {
          label: '周边1公里竞品做最好品牌的年供暖销售额',
          value: 43,
          checked: false
        },
        {
          label: '周边1公里竞品做最好品牌的年热泵销售额',
          value: 44,
          checked: false
        },
        { label: '开店原因', value: 45, checked: false },
        { label: '新店预估年壁挂炉台数', value: 46, checked: false },
        { label: '新店预估年净水台数', value: 47, checked: false },
        { label: '补贴方式', value: 48, checked: false },
        { label: '其他产品占用面积', value: 49, checked: false },
        { label: '上一年此门店供暖销售额', value: 50, checked: false },
        { label: '上一年此门店空调销售额', value: 51, checked: false },
        { label: '上一年此门店净水销售额', value: 52, checked: false },
        { label: '上一年此门店销售BDR供暖产品台数', value: 53, checked: false },
        { label: '上一年此门店销售BDR净水产品台数', value: 54, checked: false },
        { label: '上一年此门店销售BDR热泵产品台数', value: 55, checked: false },
        { label: '新店预估年热泵台数', value: 56, checked: false },
        // { label: '门店申请类型', value: 57, checked: false },
        // { label: '渠道类型', value: 58, checked: false },
        { label: '类型', value: 59, checked: false }
      ],

      Update_Fields_Id: '',
      Update_Fields_Text: '',

      form: {
        DealerId: null,
        Remake: null,
        Date: null,
        Aub_Brand: '',
        This_Dealer_BaseInfo: {
          DealerId: null,
          Name: '',
          Referred: '',
          Account: '',
          KeDealerNo: '',
          NickName: '',
          Mobile: '',
          Telephone: '',
          Level: null,
          LevelName: '',
          ProvinceId: null,
          CityId: null,
          DistrictId: null,
          Address: '',
          Delivery_ProvinceId: null,
          Delivery_CityId: null,
          Delivery_DistrictId: null,
          Delivery_Address: '',
          Parent_DealerId: null,
          Parent_Name: '',
          State: null,
          Created: null,
          IsFictitious: null
        },
        This_Dealer_OtherInfo: {
          DealerType: '',
          BusinessCategory: '',
          CompetingGoodsBrandA: '',
          CompetingGoodsBrandB: '',
          CompetingGoodsBrandC: '',
          LastYearsBDRSales: null,
          TotalSales: null,
          PercentageBDRSales: null,
          PeopleNum: null,
          DealerGrade: null,
          BlessingNote: '',
          BossName: '',
          BossPhone: '',
          BossBirthday: null,
          IsVIP: null,
          BusinessLicenseA: '',
          TreatyPhoto: '',
          TreatyPhotoType: null,
          IsSign: null,

          Update_Fields_Id: '',
          Update_Fields_Text: '',

          LY_DealerHeatingSales: '',
          LY_DealerAirConditionerSales: '',
          LY_DealerPurifiedWaterSales: '',
          LY_StoreHeatingSales: '',
          LY_StoreAirConditionerSales: '',
          LY_Store_BDR_PurifiedWaterSales: '',
          LY_Store_BDR_HeatingSalesNum: '',
          LY_Store_BDR_AirConditionerSalesNum: '',
          LY_Store_BDR_PurifiedWaterSalesNum: '',

          AS_HeatingMarketCapacity: '',
          AS_HeatPumpMarketCapacity: '',
          AS_CompetingStoresNum: '',
          AS_CompetingBrand: '',
          AS_BestCompetingBrand: '',
          AS_AnnualHeatingSalesCompetingProducts: '',
          AS_CompetitiveAnnualHeatPumpSales: '',
          AS_ReasonOpeningStore: '',

          NY_Estimate_FireplaceNum: '',
          NY_Estimate_CleanWaterNum: '',
          NY_Estimate_HeatPumpNum: '',

          SubsidyMethod: '1',
          StoreApplyType: '',

          ChannelType: '',
          First_Type: ''
        },
        This_Dealer_RelationList: [],

        VisitRecordInfo: {
          SalesVolume: '',
          TotalSalesVolume: '',
          Sampling: '',
          VisitRemake: '',
          FlagshipState: '',
          DoubleSupply: '',
          DoubleSupplyString: '',
          OtherBrand: '',
          DealerVisitInfoModelList: [],
          DealerVisitSellList: [],
          DealerSamplingSellList: [],
          ProductOtherInfo: ''
        },
        DealerPeopleNumList: [],
        InitialStorePhoto: []
      }
    };
  },

  async onLoad(options) {
    if (options.Level) {
      this.ShowLevel = options.Level;
    }
    if (options.DealerId) {
      this.form.DealerId = options.DealerId;
    }
    await this.init();
    this.$setTitle(this.title);

    this.getDealerVisitList();
  },

  computed: {
    count_A() {
      if (!this.DataBaseInfo.CompetingGoodsBrandA_BaseList) {
        return 0;
      }
      return this.DataBaseInfo.CompetingGoodsBrandA_BaseList.filter(item => item.checked).length;
    },
    count_B() {
      if (!this.DataBaseInfo.CompetingGoodsBrandB_BaseList) {
        return 0;
      }
      return this.DataBaseInfo.CompetingGoodsBrandB_BaseList.filter(item => item.Key != 80).filter(item => item.checked)
        .length;
    },
    count_C() {
      if (!this.DataBaseInfo.CompetingGoodsBrandC_BaseList) {
        return 0;
      }
      return this.DataBaseInfo.CompetingGoodsBrandC_BaseList.filter(item => item.Key != 81).filter(item => item.checked)
        .length;
    },

    fieldsOptions() {
      if (this.ShowLevel == 3) {
        return this.fieldOptions_3;
      } else if (this.ShowLevel == 2) {
        return this.fieldOptions_2;
      } else {
        return this.fieldOptions_1;
      }
    },

    tabList() {
      if (this.ShowLevel == 1) {
        return this.level1TabList;
      } else if (this.ShowLevel == 2) {
        return this.level2TabList;
      } else if (this.ShowLevel == 3) {
        return this.level3TabList;
      }
    },
    percentOfSalesVolume() {
      let SalesVolume = this.form.VisitRecordInfo.SalesVolume;
      let TotalSalesVolume = this.form.VisitRecordInfo.TotalSalesVolume;

      if (!TotalSalesVolume) {
        return 0;
      }

      if (!SalesVolume) {
        return 0;
      }
      return ((SalesVolume / TotalSalesVolume) * 100).toFixed(2);
    }
  },

  methods: {
    backToHome() {
      uni.navigateBack();
    },

    onBusinessCategoryChange(e) {
      this.form.This_Dealer_OtherInfo.BusinessCategory = e.toString();
    },
    onCompetingGoodsBrandAChange(e) {
      this.form.This_Dealer_OtherInfo.CompetingGoodsBrandA = e.toString();
    },

    onFirstTypeChange(e) {
      this.form.This_Dealer_OtherInfo.First_Type = e.toString();
    },

    onCompetingGoodsBrandBChange(e) {
      this.form.This_Dealer_OtherInfo.CompetingGoodsBrandB = e.toString();
    },
    onCompetingGoodsBrandCChange(e) {
      this.form.This_Dealer_OtherInfo.CompetingGoodsBrandC = e.toString();
    },

    onCheckAllChange(e, item) {
      item.fields.forEach(field => (field.checked = e.value));

      item.selectedFields = item.fields.filter(field => field.checked).map(field => field.value);

      this.selectedFields = this.fieldsOptions
        .map($item => {
          return $item.selectedFields;
        })
        .flat();

      this.Update_Fields_Id = this.selectedFields.join(',');
      this.Update_Fields_Text = this.fieldOptions
        .filter(field => this.selectedFields.includes(field.value))
        .map(field => field.label)
        .join(',');

      console.log('update_field_id', this.Update_Fields_Id);
      console.log('update_field_text', this.Update_Fields_Text);
    },

    onSelectedFieldChange(e, item) {
      item.selectedFields = e;

      if (e.length == 0) {
        item.checked = false;
      }

      if (e.length == item.fields.length) {
        item.checked = true;
      }

      this.selectedFields = this.fieldsOptions
        .map($item => {
          return $item.selectedFields;
        })
        .flat();

      this.Update_Fields_Id = this.selectedFields.join(',');
      this.Update_Fields_Text = this.fieldOptions
        .filter(field => this.selectedFields.includes(field.value))
        .map(field => field.label)
        .join(',');

      console.log('update_field_id', this.Update_Fields_Id);
      console.log('update_field_text', this.Update_Fields_Text);
    },

    selectFile(index) {
      this.currentIndex = index;
      this.$refs.upload.selectFile();
    },

    removeSampling(index) {
      this.form.VisitRecordInfo.DealerSamplingSellList.splice(index, 1);
    },

    removeVisitSell(index) {
      this.form.VisitRecordInfo.DealerVisitSellList.splice(index, 1);
    },

    addSampling() {
      this.form.VisitRecordInfo.DealerSamplingSellList.push({
        BrandName: '',
        BrandId: '',
        ProductModel: '',
        productName: '',
        Number: '',
        brandIndex: -1,
        productIndex: -1,
        productList: []
      });
    },

    addVisitSell() {
      this.form.VisitRecordInfo.DealerVisitSellList.push({
        BrandName: '',
        BrandId: '',
        ProductId: '',
        productName: '',
        Number: '',
        brandIndex: -1,
        productIndex: -1,
        productList: []
      });
    },

    addPersonCount() {
      this.form.DealerPeopleNumList.push({
        Title: '',
        Num: ''
      });
    },

    removePersonCount(index) {
      this.form.DealerPeopleNumList.splice(index, 1);
    },

    onPickerChange(e, samplingIndex) {
      let brandId, name;
      if (e[0].label && e[0].value) {
        name = e[0].label;
        brandId = e[0].value;
        this.form.VisitRecordInfo.DealerSamplingSellList[
          samplingIndex
        ].brandIndex = this.DataBaseInfo.CompetingGoodsBrandA_BaseList.findIndex(item => item.Key == e[0].value);
        this.form.VisitRecordInfo.DealerSamplingSellList[samplingIndex].BrandName = name;
      } else {
        name = this.DataBaseInfo.CompetingGoodsBrandA_BaseList[0].Value;
        brandId = this.DataBaseInfo.CompetingGoodsBrandA_BaseList[0].Key;
        this.form.VisitRecordInfo.DealerSamplingSellList[samplingIndex].brandIndex = 0;
        this.form.VisitRecordInfo.DealerSamplingSellList[samplingIndex].BrandName = name;
      }
      this.getDoorVisitBrandProductList(brandId, samplingIndex, 1);
    },

    onProductPickerChange(e, listIndex, type) {
      let productId;
      if (e[0].label && e[0].value) {
        productId = e[0].value;
      } else {
        if (type == 1) {
          productId = this.form.VisitRecordInfo.DealerSamplingSellList[listIndex].productList[0].Id;
        }
        if (type == 2) {
          productId = this.form.VisitRecordInfo.DealerVisitSellList[listIndex].productList[0].Id;
        }
      }

      if (type == 1) {
        let productList = this.form.VisitRecordInfo.DealerSamplingSellList[listIndex].productList;
        let productIndex = productList.findIndex(item => item.Id == productId);
        if (productIndex > -1) {
          this.form.VisitRecordInfo.DealerSamplingSellList[listIndex].productIndex = productIndex;
          this.form.VisitRecordInfo.DealerSamplingSellList[listIndex].productName = productList[productIndex].Text;
          this.form.VisitRecordInfo.DealerSamplingSellList[listIndex].ProductModel = productList[productIndex].Text;
        }
      }

      if (type == 2) {
        let productList = this.form.VisitRecordInfo.DealerVisitSellList[listIndex].productList;
        let productIndex = productList.findIndex(item => item.Id == productId);
        if (productIndex > -1) {
          this.form.VisitRecordInfo.DealerVisitSellList[listIndex].productIndex = productIndex;
          this.form.VisitRecordInfo.DealerVisitSellList[listIndex].productName = productList[productIndex].Text;
          this.form.VisitRecordInfo.DealerVisitSellList[listIndex].ProductId = productList[productIndex].Id;
        }
      }
    },

    onVisitSellPickerChange(e, visitSellIndex) {
      let brandId, name;
      if (e[0].label && e[0].value) {
        name = e[0].label;
        brandId = e[0].value;
        this.form.VisitRecordInfo.DealerVisitSellList[
          visitSellIndex
        ].brandIndex = this.DataBaseInfo.CompetingGoodsBrandA_BaseList.findIndex(item => item.Key == e[0].value);
        this.form.VisitRecordInfo.DealerVisitSellList[visitSellIndex].BrandName = name;
        this.form.VisitRecordInfo.DealerVisitSellList[visitSellIndex].BrandId = brandId;
      } else {
        name = this.DataBaseInfo.CompetingGoodsBrandA_BaseList[0].Value;
        brandId = this.DataBaseInfo.CompetingGoodsBrandA_BaseList[0].Key;
        this.form.VisitRecordInfo.DealerVisitSellList[visitSellIndex].brandIndex = 0;
        this.form.VisitRecordInfo.DealerVisitSellList[visitSellIndex].BrandName = name;
        this.form.VisitRecordInfo.DealerVisitSellList[visitSellIndex].BrandId = brandId;
      }
      this.getDoorVisitBrandProductList(brandId, visitSellIndex, 2);
    },

    onFileChange(list, name) {
      const file = list[list.length - 1].file;
      this.$fileUpload(file).then(res => {
        this.DealerVisitCategorylistModel[this.currentIndex].Pic = res.key;
      });
    },

    async getDoorVisitInfo() {
      this.$u.api
        .getDoorVisitInfo({
          DealerId: this.form.DealerId
        })
        .then(res => {
          if (res.DealerVisit_Sell) {
            this.form.VisitRecordInfo.DealerVisitSellList = res.DealerVisit_Sell.map((item, index) => {
              let brand = this.DataBaseInfo.CompetingGoodsBrandA_BaseList.find(i => i.Key == item.Brand);

              return {
                BrandName: brand.Value,
                BrandId: item.Brand,
                ProductId: item.ProductId,
                ProductModel: item.ProductModel,
                productName: item.ProductModel,
                Number: item.Number,
                brandIndex: -1,
                productIndex: -1,
                productList: []
              };
            });
          }
        });
    },

    async getDoorVisitBrandProductList(brandId, listIndex, type) {
      this.$u.api
        .getDoorVisitBrandProductList({
          BrandId: brandId
        })
        .then(res => {
          console.log(res);
          const { ResultCode, LogisticsList } = res;
          if (ResultCode == 0) {
            if (type == 1) {
              this.form.VisitRecordInfo.DealerSamplingSellList[listIndex].productList = LogisticsList;
            }
            if (type == 2) {
              this.form.VisitRecordInfo.DealerVisitSellList[listIndex].productList = LogisticsList;
            }
          }
        });
    },

    getDealerVisitList() {
      this.$u.api
        .getDealerVisitList({
          DoorType: 0,
          DealerId: this.form.DealerId
        })
        .then(res => {
          const {
            DealerVisitCategorylistModel,
            DealerSamplingSellMoodeList,
            DealerGrade_VisitList,
            DealerVisitInfoModelList,
            CompetingGoodsBrandDoubleSupply,
            FlagshipState,
            SalesVolume,
            Sampling,
            TotalSalesVolume,
            VisitRemake,
            ProductOtherInfo,
            DoubleSupply,
            DoubleSupplyString,
            OtherBrand
          } = res;
          this.DealerGrade_VisitList = DealerGrade_VisitList;

          this.form.VisitRecordInfo.FlagshipState = FlagshipState;
          this.form.VisitRecordInfo.Sampling = Sampling;
          this.form.VisitRecordInfo.SalesVolume = SalesVolume;
          this.form.VisitRecordInfo.TotalSalesVolume = TotalSalesVolume;
          this.form.VisitRecordInfo.OtherBrand = OtherBrand;

          this.form.VisitRecordInfo.VisitRemake = VisitRemake;
          this.form.VisitRecordInfo.ProductOtherInfo = ProductOtherInfo;
          this.form.VisitRecordInfo.DoubleSupply = DoubleSupply;
          this.form.VisitRecordInfo.DoubleSupplyString = DoubleSupplyString;

          if (CompetingGoodsBrandDoubleSupply) {
            let doubleSupplyStringArr = [];
            if (DoubleSupplyString) {
              doubleSupplyStringArr = DoubleSupplyString.split(',');
            }
            CompetingGoodsBrandDoubleSupply.forEach(item => {
              item.checked = doubleSupplyStringArr.includes(String(item.Key));
            });
          }
          this.doubleApplyBrandList = CompetingGoodsBrandDoubleSupply;

          DealerVisitCategorylistModel &&
            DealerVisitCategorylistModel.forEach(item => {
              let imgInfo = DealerVisitInfoModelList.find(info => info.DealerVisitCategoryId == item.Id);
              item.Pic = '';
              item.checked = false;
              if (imgInfo) {
                item.Pic = imgInfo.Pic;
                item.checked = true;
              }
            });

          this.DealerVisitCategorylistModel = DealerVisitCategorylistModel;
          if (DealerSamplingSellMoodeList && DealerSamplingSellMoodeList.length > 0) {
            this.form.VisitRecordInfo.Sampling = 1;
            DealerSamplingSellMoodeList.forEach(item => (item.productName = item.ProductModel));
            this.form.VisitRecordInfo.DealerSamplingSellList = DealerSamplingSellMoodeList;
          }

          this.doubleApplyBrandList = CompetingGoodsBrandDoubleSupply;
        });
    },

    removeRelation(index) {
      this.This_Dealer_RelationList.splice(parseInt(index), 1);
      this.$nextTick(() => {
        this.$refs.relationsForm.initRelations(this.This_Dealer_RelationList);
      });
    },

    submit() {
      let me = this;
      me.btnDisabled = true;
      const applyForm = this.$refs.applyForm.form;
      // const relationsForm = this.$refs.relationsForm;
      const basicForm = this.$refs.basicForm;
      const storeForm = this.$refs.storeForm;

      const bossForm = this.$refs.bossForm;
      this.form.Date = applyForm.ApplyTime;
      this.form.Remake = applyForm.Remark;

      // this.form.This_Dealer_RelationList = relationsForm.list;

      // if (this.ShowLevel == 3) {
      // 	this.form.This_Dealer_BaseInfo = { ...this.form.This_Dealer_BaseInfo, ...storeForm.form.Dealer_BaseInfo };
      // 	this.form.This_Dealer_OtherInfo = { ...this.form.This_Dealer_OtherInfo, ...bossForm.form };
      // } else {
      this.form.This_Dealer_BaseInfo = {
        ...this.form.This_Dealer_BaseInfo,
        ...basicForm.form.Dealer_BaseInfo
      };

      basicForm.form.Dealer_OtherInfo.ChannelType = this.form.This_Dealer_OtherInfo.ChannelType;
      basicForm.form.Dealer_OtherInfo.First_Type = this.form.This_Dealer_OtherInfo.First_Type;

      basicForm.form.Dealer_OtherInfo.DealerType = this.form.This_Dealer_OtherInfo.DealerType;
      basicForm.form.Dealer_OtherInfo.BusinessCategory = this.form.This_Dealer_OtherInfo.BusinessCategory;
      basicForm.form.Dealer_OtherInfo.CompetingGoodsBrandA = this.form.This_Dealer_OtherInfo.CompetingGoodsBrandA;
      basicForm.form.Dealer_OtherInfo.CompetingGoodsBrandB = this.form.This_Dealer_OtherInfo.CompetingGoodsBrandB;
      basicForm.form.Dealer_OtherInfo.CompetingGoodsBrandC = this.form.This_Dealer_OtherInfo.CompetingGoodsBrandC;

      basicForm.form.Dealer_OtherInfo.LY_DealerHeatingSales = this.form.This_Dealer_OtherInfo.LY_DealerHeatingSales;
      basicForm.form.Dealer_OtherInfo.LY_DealerAirConditionerSales = this.form.This_Dealer_OtherInfo.LY_DealerAirConditionerSales;
      basicForm.form.Dealer_OtherInfo.LY_DealerPurifiedWaterSales = this.form.This_Dealer_OtherInfo.LY_DealerPurifiedWaterSales;
      basicForm.form.Dealer_OtherInfo.LY_StoreHeatingSales = this.form.This_Dealer_OtherInfo.LY_StoreHeatingSales;
      basicForm.form.Dealer_OtherInfo.LY_StoreAirConditionerSales = this.form.This_Dealer_OtherInfo.LY_StoreAirConditionerSales;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales = this.form.This_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum = this.form.This_Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum = this.form.This_Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum = this.form.This_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum;

      basicForm.form.Dealer_OtherInfo.LastYearsBDRSales = this.form.This_Dealer_OtherInfo.LastYearsBDRSales;
      basicForm.form.Dealer_OtherInfo.TotalSales = this.form.This_Dealer_OtherInfo.TotalSales;

      basicForm.form.Dealer_OtherInfo.AS_HeatingMarketCapacity = this.form.This_Dealer_OtherInfo.AS_HeatingMarketCapacity;
      basicForm.form.Dealer_OtherInfo.AS_HeatPumpMarketCapacity = this.form.This_Dealer_OtherInfo.AS_HeatPumpMarketCapacity;
      basicForm.form.Dealer_OtherInfo.AS_CompetingStoresNum = this.form.This_Dealer_OtherInfo.AS_CompetingStoresNum;
      basicForm.form.Dealer_OtherInfo.AS_CompetingBrand = this.form.This_Dealer_OtherInfo.AS_CompetingBrand;
      basicForm.form.Dealer_OtherInfo.AS_BestCompetingBrand = this.form.This_Dealer_OtherInfo.AS_BestCompetingBrand;
      basicForm.form.Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts = this.form.This_Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts;
      basicForm.form.Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales = this.form.This_Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales;
      basicForm.form.Dealer_OtherInfo.AS_ReasonOpeningStore = this.form.This_Dealer_OtherInfo.AS_ReasonOpeningStore;

      basicForm.form.Dealer_OtherInfo.NY_Estimate_FireplaceNum = this.form.This_Dealer_OtherInfo.NY_Estimate_FireplaceNum;
      basicForm.form.Dealer_OtherInfo.NY_Estimate_CleanWaterNum = this.form.This_Dealer_OtherInfo.NY_Estimate_CleanWaterNum;
      basicForm.form.Dealer_OtherInfo.NY_Estimate_HeatPumpNum = this.form.This_Dealer_OtherInfo.NY_Estimate_HeatPumpNum;

      basicForm.form.Dealer_OtherInfo.SubsidyMethod = this.form.This_Dealer_OtherInfo.SubsidyMethod;
      basicForm.form.Dealer_OtherInfo.StoreApplyType = this.form.This_Dealer_OtherInfo.StoreApplyType;

      this.form.This_Dealer_OtherInfo = {
        ...this.form.This_Dealer_OtherInfo,
        ...basicForm.form.Dealer_OtherInfo
      };

      this.form.This_Dealer_OtherInfo.BossName = bossForm.form.BossName;
      this.form.This_Dealer_OtherInfo.BossPhone = bossForm.form.BossPhone;
      this.form.This_Dealer_OtherInfo.BossBirthday = bossForm.form.BossBirthday;
      this.form.This_Dealer_OtherInfo.IsVIP = bossForm.form.IsVIP;
      this.form.This_Dealer_OtherInfo.BlessingNote = bossForm.form.BlessingNote;

      let SalesVolume = this.form.This_Dealer_OtherInfo.LastYearsBDRSales;
      let TotalSalesVolume = this.form.This_Dealer_OtherInfo.TotalSales;
      let percentOfSalesVolume = 0;

      if (!TotalSalesVolume) {
        percentOfSalesVolume = 0;
      }

      if (!SalesVolume) {
        percentOfSalesVolume = 0;
      }

      this.form.This_Dealer_OtherInfo.PercentageBDRSales = ((SalesVolume / TotalSalesVolume) * 100).toFixed(2);

      this.form.VisitRecordInfo.DealerVisitInfoModelList = this.DealerVisitCategorylistModel.filter(
        item => item.checked
      ).map(item => {
        return {
          Pic: item.Pic,
          DealerVisitCategoryId: item.Id
        };
      });

      this.form.This_Dealer_OtherInfo.Update_Fields_Id = this.Update_Fields_Id;
      this.form.This_Dealer_OtherInfo.Update_Fields_Text = this.Update_Fields_Text;

      console.log(this.form);

      if (!this.form.This_Dealer_OtherInfo.Update_Fields_Id) {
        this.$u.toast('请选择要修改的字段');
        return false;
      }

      this.$u.api.updateInformationApply(this.form).then(res => {
        const { ResultCode, ResultMessage } = res;
        if (ResultCode === 1) {
          this.$u.toast(ResultMessage);
          setTimeout(() => {
            uni.navigateBack();
          }, 1000);
        } else {
          me.btnDisabled = false;
        }
      });
    },

    onDoubleSupplyChange(e) {
      this.form.VisitRecordInfo.DoubleSupplyString = this.doubleApplyBrandList
        .filter(item => item.checked)
        .map(item => item.Key)
        .toString();
    },

    backToList() {
      // this.$u.route({
      // 	url: '/pages/review/'
      // })
    },

    initFields(This_Dealer_OtherInfo) {
      if (This_Dealer_OtherInfo) {
        if (This_Dealer_OtherInfo.Update_Fields_Id) {
          this.Update_Fields_Id = This_Dealer_OtherInfo.Update_Fields_Id.split(',').map(Number);

          this.selectedFields = this.Update_Fields_Id;

          this.Update_Fields_Text = This_Dealer_OtherInfo.Update_Fields_Text.split(',');

          this.fieldOptions.forEach(field => {
            if (this.Update_Fields_Id.includes(field.value)) {
              field.checked = true;
            }
          });
        }
      }
    },

    async init() {
      this.loading = true;
      this.$u.api
        .getInitInformationUpdateDetail({
          DealerId: this.form.DealerId
        })
        .then(res => {
          const {
            ResultCode,
            ShowLevel,
            DataBaseInfo,
            DealerAuditInfo,
            DoorPhotoAuditInfo,
            DoorPhotoList,
            Door_Dealer_BaseInfo,
            Double_Dealer_BaseInfo,
            First_Dealer_BaseInfo,
            This_Dealer_OtherInfo,
            This_Dealer_RelationList,
            DirectorList,
            SalseList,
            DealerTerminalList,
            TeamList,
            SeniorDealerTerminalList,
            DealerDivisionList,
            RegionalDirectorList,
            SalesServiceList,
            AuditForList,
            InitialStorePhoto,
            Store_Location_List,
            DealerPeopleNumList,
            First_Type_List,
            Update_Count
          } = res;

          if (ResultCode === 1) {
            this.ShowLevel = ShowLevel;

            this.Update_Count = Update_Count;

            if (this.Update_Count == 0) {
              this.fieldOptions_1.forEach(item => {
                item.checked = true;
                item.fields.forEach(item => {
                  item.checked = true;
                });
                item.selectedFields = item.fields.filter(field => field.checked).map(field => field.value);
              });
              this.fieldOptions_2.forEach(item => {
                item.checked = true;
                item.fields.forEach(item => {
                  item.checked = true;
                });
                item.selectedFields = item.fields.filter(field => field.checked).map(field => field.value);
              });
              this.fieldOptions_3.forEach(item => {
                item.checked = true;
                item.fields.forEach(item => {
                  item.checked = true;
                });
                item.selectedFields = item.fields.filter(field => field.checked).map(field => field.value);
              });

              this.selectedFields = this.fieldsOptions
                .map($item => {
                  return $item.selectedFields;
                })
                .flat();

              this.Update_Fields_Id = this.selectedFields.join(',');
              this.Update_Fields_Text = this.fieldOptions
                .filter(field => this.selectedFields.includes(field.value))
                .map(field => field.label)
                .join(',');
            }

            if (First_Type_List) {
              First_Type_List.forEach(item => {
                let firstType = This_Dealer_OtherInfo.First_Type ? This_Dealer_OtherInfo.First_Type : '';
                const checked = firstType.split(',').indexOf(String(item.Key)) > -1;
                this.$set(item, 'checked', checked);
              });

              this.First_Type_List = First_Type_List;
            }

            if (DealerPeopleNumList) {
              this.form.DealerPeopleNumList = DealerPeopleNumList;
            }

            this.initFields(This_Dealer_OtherInfo);

            if (this.ShowLevel == 3) {
              this.form.InitialStorePhoto = InitialStorePhoto;
            }

            this.DataBaseInfo = DataBaseInfo;

            this.relationsMetaData.DirectorList = DirectorList;
            this.relationsMetaData.SalseList = SalseList;
            this.relationsMetaData.DealerTerminalList = DealerTerminalList;
            this.relationsMetaData.TeamList = TeamList;
            this.relationsMetaData.SeniorDealerTerminalList = SeniorDealerTerminalList;
            this.relationsMetaData.DealerDivisionList = DealerDivisionList;
            this.relationsMetaData.RegionalDirectorList = RegionalDirectorList;
            this.relationsMetaData.SalesServiceList = SalesServiceList;

            if (This_Dealer_RelationList) {
              this.This_Dealer_RelationList = This_Dealer_RelationList;
            }

            if (DealerAuditInfo) {
              this.DealerAuditInfo = DealerAuditInfo;
            }

            if (DoorPhotoAuditInfo) {
              this.DoorPhotoAuditInfo = DoorPhotoAuditInfo;
            }

            if (DoorPhotoList) {
              this.DoorPhotoList = DoorPhotoList;
            }

            if (Door_Dealer_BaseInfo) {
              this.Door_Dealer_BaseInfo = Door_Dealer_BaseInfo;
            }

            if (Double_Dealer_BaseInfo) {
              this.Double_Dealer_BaseInfo = Double_Dealer_BaseInfo;
            }

            if (First_Dealer_BaseInfo) {
              this.First_Dealer_BaseInfo = First_Dealer_BaseInfo;
            }

            if (This_Dealer_OtherInfo) {
              this.This_Dealer_OtherInfo = This_Dealer_OtherInfo;
              this.form.This_Dealer_OtherInfo = {
                ...this.form.This_Dealer_OtherInfo,
                ...This_Dealer_OtherInfo
              };

              this.otherInfo = { ...this.otherInfo, ...This_Dealer_OtherInfo };
            }

            this.DataBaseInfo.BusinessCategory_BaseList.forEach(item => {
              const checked = This_Dealer_OtherInfo.BusinessCategory.split(',').indexOf(String(item.Key)) > -1;
              this.$set(item, 'checked', checked);
            });
            this.DataBaseInfo.CompetingGoodsBrandA_BaseList.forEach(item => {
              const checked = This_Dealer_OtherInfo.CompetingGoodsBrandA.split(',').indexOf(String(item.Key)) > -1;
              this.$set(item, 'checked', checked);
            });
            this.DataBaseInfo.CompetingGoodsBrandB_BaseList.forEach(item => {
              const checked = This_Dealer_OtherInfo.CompetingGoodsBrandB.split(',').indexOf(String(item.Key)) > -1;
              this.$set(item, 'checked', checked);
            });
            this.DataBaseInfo.CompetingGoodsBrandC_BaseList.forEach(item => {
              const checked = This_Dealer_OtherInfo.CompetingGoodsBrandC.split(',').indexOf(String(item.Key)) > -1;
              this.$set(item, 'checked', checked);
            });

            let dealerBaseInfo = First_Dealer_BaseInfo;

            if (ShowLevel == 1) {
              this.form.This_Dealer_BaseInfo = dealerBaseInfo;
              // this.$refs.relationsForm.initRelations(This_Dealer_RelationList);
              this.$refs.basicForm.initForm({
                Dealer_BaseInfo: dealerBaseInfo,
                Dealer_OtherInfo: This_Dealer_OtherInfo,
                DealerAuditInfo: DealerAuditInfo,
                AuditForList: AuditForList
              });
            }

            if (ShowLevel == 2) {
              dealerBaseInfo = Double_Dealer_BaseInfo;
              this.form.This_Dealer_BaseInfo = dealerBaseInfo;
              this.$refs.basicForm.initForm({
                Dealer_BaseInfo: dealerBaseInfo,
                Dealer_OtherInfo: This_Dealer_OtherInfo,
                DealerAuditInfo: DealerAuditInfo,
                AuditForList: AuditForList
              });
            }

            if (ShowLevel == 3) {
              dealerBaseInfo = Door_Dealer_BaseInfo;
              this.form.This_Dealer_BaseInfo = dealerBaseInfo;
              this.$refs.basicForm.initForm({
                Dealer_BaseInfo: dealerBaseInfo,
                Dealer_OtherInfo: This_Dealer_OtherInfo,
                DealerAuditInfo: DealerAuditInfo,
                AuditForList: AuditForList,
                Store_Location_List
              });
              // this.$refs.storeForm.initForm({
              // 	Dealer_BaseInfo: dealerBaseInfo,
              // 	Dealer_OtherInfo: This_Dealer_OtherInfo,
              // 	DealerDetail_Audit: DealerAuditInfo,
              // 	AuditForList: AuditForList
              // });
            }

            this.$nextTick(() => {
              this.$refs.bossForm.initForm(This_Dealer_OtherInfo);
            });
            this.loadCity = true;

            this.getDoorVisitInfo();
          }
        })
        .finally(() => {
          this.loading = false;
        });
    }
  }
};
</script>

<style lang="scss">
.visit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 240rpx;
  gap: 20rpx 20rpx;
  padding: 20rpx;

  .visit-item {
    display: flex;
    flex-direction: column;
    text-align: left;

    .title {
      width: 200rpx;
    }
  }
}

.samling-item {
  background-color: #ffffff;
  padding: 0 20rpx;
}
</style>
